|
|
 |
|
|
|
|
' Multiply two matrices together. Public Sub m3MatMultiply(Result() As Single, _
A() As Single, B() As Single)
Result(1, 1) = A(1, 1) * B(1, 1) + A(1, 2) * B(2, 1) + _
A(1, 3) * B(3, 1)
Result(1, 2) = A(1, 1) * B(1, 2) + A(1, 2) * B(2, 2) + _
A(1, 3) * B(3, 2)
Result(1, 3) = A(1, 1) * B(1, 3) + A(1, 2) * B(2, 3) + _
A(1, 3) * B(3, 3)
Result(1, 4) = 0#
Result(2, 1) = A(2, 1) * B(1, 1) + A(2, 2) * B(2, 1) + _
A(2, 3) * B(3, 1)
Result(2, 2) = A(2, 1) * B(1, 2) + A(2, 2) * B(2, 2) + _
A(2, 3) * B(3, 2)
Result(2, 3) = A(2, 1) * B(1, 3) + A(2, 2) * B(2, 3) + _
A(2, 3) * B(3, 3)
Result(2, 4) = 0#
Result(3, 1) = A(3, 1) * B(1, 1) + A(3, 2) * B(2, 1) + _
A(3, 3) * B(3, 1)
Result(3, 2) = A(3, 1) * B(1, 2) + A(3, 2) * B(2, 2) + _
A(3, 3) * B(3, 2)
Result(3, 3) = A(3, 1) * B(1, 3) + A(3, 2) * B(2, 3) + _
A(3, 3) * B(3, 3)
Result(3, 4) = 0#
Result(4, 1) = A(4, 1) * B(1, 1) + A(4, 2) * B(2, 1) + _
A(4, 3) * B(3, 1) + B(4, 1)
Result(4, 2) = A(4, 1) * B(1, 2) + A(4, 2) * B(2, 2) + _
A(4, 3) * B(3, 2) + B(4, 2)
Result(4, 3) = A(4, 1) * B(1, 3) + A(4, 2) * B(2, 3) + _
A(4, 3) * B(3, 3) + B(4, 3)
Result(4, 4) = 1#
End Sub |
|
|
|
|
|
|
|
|
These routines work for most transformation matrices, but the perspective transformation matrix described later in this chapter does not contain 0, 0, 0, 1 in its final column. That means you cannot use these Visual Basic subroutines when you are using a perspective transformation. Instead, you should use the following versions that do not assume the transformation matrices contain 0, 0, 0, 1 in their final columns. |
|
|
|
 |
|
|
|
|
' Apply a transformation matrix to a point where
' the transformation may not have 0, 0, 0, 1 in
' its final column. Public Sub m3ApplyFull(V() As Single, M() As Single, _
Result() As Single)
Dim i As Integer
Dim j As Integer
Dim value As Single |
|
|
|
|
|